import Vue from 'vue'
import VueRouter from 'vue-router'

import Login from '@/views/login/index.vue'
import Layout from '@/views/layout/index.vue'
import Home from '@/views/home/home.vue'

// 产品
const Product = ()=>import('@/views/product/index.vue') //按需导入
const ProductCategory = ()=>import('@/views/product/category/index.vue') 
const ProductList = ()=>import('@/views/product/list/index.vue') 
const AddProduct = ()=>import('@/views/product/addProduct/index.vue')

// 订单
const Order = ()=>import('@/views/order/index.vue')
const OrderCollect = ()=>import('@/views/order/collect/index.vue')
const OrderVertify = ()=>import('@/views/order/vertify/index.vue')
const OrderList = ()=>import('@/views/order/list/index.vue')

// 广告
const Advert = ()=>import('@/views/advert/index.vue')
const AdvertList = ()=>import('@/views/advert/list/index.vue')


Vue.use(VueRouter)

const routes = [
  {
    path:'/',
    component:Layout,
    children:[
      // 首页
      {
        path:'/',
        name:'home',
        component:Home
      },
      // 产品
      {
        path:'/product',
        name:'product',
        component:Product,
        children:[
          {
            path:'list', //访问路径，/prouduct/list
            name:'productList',
            component:ProductList
          },
          {
            path:'category',
            name:'productCategory',
            component:ProductCategory
          },
          {
            path:'addProduct',
            name:'addProduct',
            component:AddProduct,
            meta:{
              activeMenu:'/product/list'
            },
          },
          {
            path:'editProduct',
            name:'editProduct',
            component:AddProduct,
            meta:{
              activeMenu:'/product/list'
            },
          }
        ]
      },
      // 订单
      {
        path:'/order',
        name:'order',
        component:Order,
        children:[
          {
            path:'collect',
            name:'orderCollect',
            component:OrderCollect
          },
          {
            path:'vertify',
            name:'orderVertify',
            component:OrderVertify
          },
          {
            path:'orderlist',
            name:'orderList',
            component:OrderList
          }
        ]
      },
      // 广告
      {
        path:'/advert',
        name:'advert',
        component:Advert,
        children:[
          {
            path:'list',
            name:'advertList',
            component:AdvertList
          }
        ]
      },
      
    ]
  },
  {
    path:'/login',
    component:Login,
    name:'login'
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
